Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
is-directory
Advanced tools
Extends `stats.isDirectory()`, returns `true` if a filepath is a directory.
The 'is-directory' npm package is a simple utility that allows developers to check if a given path is a directory. It provides a straightforward API for synchronous and asynchronous checks, making it useful in various file system operations where such validation is necessary.
Synchronous Directory Check
This feature allows you to synchronously check if a specified path is a directory. It is useful when you need an immediate result and are working in a synchronous code context.
const isDirectory = require('is-directory');
const result = isDirectory.sync('/path/to/directory');
console.log(result); // outputs true if path is a directory, false otherwise
Asynchronous Directory Check
This feature provides an asynchronous method to check if a path is a directory. It is particularly useful in non-blocking environments where operations should not interrupt the main application flow.
const isDirectory = require('is-directory');
isDirectory('/path/to/directory', function(err, dir) {
if (err) throw err;
console.log(dir); // outputs true if path is a directory, false otherwise
});
fs-extra is an extension of the native 'fs' module in Node.js. It includes additional methods like 'ensureDir' which can be used to check if a directory exists and create it if it doesn't. This package offers more comprehensive file system operations compared to 'is-directory' which focuses only on directory checking.
node-dir provides utilities for reading directories, files, and their paths. It can check if a path is a directory, but it also includes capabilities to read directories recursively, which is not a feature of 'is-directory'. This makes node-dir suitable for applications that require more than just directory checking.
Extends
stats.isDirectory()
, returnstrue
if a filepath is a directory.
npm i is-directory --save-dev
npm test
var isDir = require('is-directory');
isDir('README.md');
//=> 'false'
isDir('test');
//=> 'true'
function isFile(filepath) {
return !isDir(filepath);
}
isFile('README.md');
//=> true
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on November 17, 2014.
FAQs
Returns true if a filepath exists on the file system and it's directory.
The npm package is-directory receives a total of 5,843,574 weekly downloads. As such, is-directory popularity was classified as popular.
We found that is-directory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.